package com.maker.generator.service.impl;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dwork.base.pagination.Page;
import com.dwork.base.pagination.Pagination;
import com.maker.generator.dao.MetaGenAttrDao;
import com.maker.generator.dao.MetaGenDBInfoDao;
import com.maker.generator.dao.MetaGenObjDao;
import com.maker.generator.entity.MetaGenAttr;
import com.maker.generator.entity.MetaGenDBInfo;
import com.maker.generator.entity.MetaGenObj;
import com.maker.generator.service.IGenService;

@Service
public class GenServiceImpl implements IGenService {

	@Autowired
	private MetaGenObjDao metaGenObjDao;
	@Autowired
	private MetaGenAttrDao metaGenAttrDao;
	@Autowired
	private MetaGenDBInfoDao metaGenDBInfoDao;
	
	@Transactional
	public MetaGenObj save(MetaGenObj entity){
		this.metaGenObjDao.save(entity);
		return entity;
	}
	@Transactional
	public MetaGenAttr save(MetaGenAttr entity){
		this.metaGenAttrDao.save(entity);
		return entity;
	}
	@Transactional
	public MetaGenObj update(MetaGenObj entity){
		this.metaGenObjDao.update(entity);
		return entity;
	}
	@Transactional
	public MetaGenAttr update(MetaGenAttr entity){
		this.metaGenAttrDao.update(entity);
		return entity;
	}
	public MetaGenObj findMetaGenObjById(Long id){
		MetaGenObj entity = this.metaGenObjDao.findById(id);
		return entity;
	}
	
	public MetaGenAttr findMetaGenAttrById(Long id){
		MetaGenAttr entity = this.metaGenAttrDao.findById(id);
		return entity;
	}
	@Transactional
	public Boolean delete(Long id){
		Integer mark = this.metaGenObjDao.deleteById(id);
		return (mark.intValue() == 0)?Boolean.FALSE:Boolean.TRUE;
	}
	@Transactional
	public Boolean deleteMetaGenObjByIds(List<Long> ids){
		Integer mark = this.metaGenObjDao.deleteByIds(ids);
		return (mark.intValue() == ids.size())?Boolean.FALSE:Boolean.TRUE;
	}
	@Transactional
	public Boolean deleteMetaGenAttrByIds(List<Long> ids){
		Integer mark = this.metaGenAttrDao.deleteByIds(ids);
		return (mark.intValue() == ids.size())?Boolean.FALSE:Boolean.TRUE;
	}
	public Pagination<MetaGenObj> queryMetaGenObjList(Page page, Map<String,Object> paramMap) {
		
		Pagination<MetaGenObj> metaGenObjPage = metaGenObjDao.findByPage(page, paramMap);
		
		
		return metaGenObjPage;
	}
	public Pagination<MetaGenAttr> queryMetaGenAttrList(Page page, Map<String,Object> paramMap) {
		
		Pagination<MetaGenAttr> metaGenAttrPage = metaGenAttrDao.findByPage(page, paramMap);
		
		return metaGenAttrPage;
	}
	
	public Pagination<MetaGenDBInfo> queryMetaGenDBInfoList(Page page, Map<String,Object> paramMap) {
		
		Pagination<MetaGenDBInfo> metaGenDBInfoPage = metaGenDBInfoDao.findByPage(page, paramMap);
		
		return metaGenDBInfoPage;
	}
	
	
	
	
}
